
using System.Data.Odbc;
using Xunit.Abstractions;

namespace kldbTest;

// 参考 https://learn.microsoft.com/zh-cn/dotnet/api/system.data.odbc.odbcdatareader?view=net-8.0

public class UnitTest1
{
    private readonly ITestOutputHelper _testOutputHelper;

    public UnitTest1(ITestOutputHelper testOutputHelper)
    {
        _testOutputHelper = testOutputHelper;
    }

    [Fact]
    public void TestQuery01()
    {
        const String connString =
            "Driver=KLODBC;Server=192.168.59.181;Database=pengrui;User=pengrui01;Password=pengrui123;Port=6688;Autocommit=true;UseSSL=false;CharSet=UTF8";
        using (var conn = new OdbcConnection())
        {
            conn.ConnectionString = connString;
            conn.Open();
            // query

            OdbcCommand c = new OdbcCommand("select * from test01", conn);
            var reader = c.ExecuteReader();
            while (reader.Read())
            {
                _testOutputHelper.WriteLine("record={0} {1}",reader[0],reader[1]);
                // Assert.That(reader[0].Equals(1), "id = 1");
                Assert.Equal(1,reader[0]);
                Assert.Equal("鹏锐",reader[1].ToString());
            }
            reader.Close();
        }
    }
}